#!/usr/bin/env bash
# shellcheck disable=SC2034,SC1091

if [[ $1 == 'true' ]]; then
    source /tmp/.secrets
    if ! curl -LsS https://dlm.mariadb.com/enterprise-release-helpers/mariadb_es_repo_setup | bash -s -- --mariadb-server-version="$2" --token="${TOKEN}" --apply >/dev/null 2>&1; then
        echo "Enterprise Repo Setup Failed: Check Release Number"
        exit 1
    fi
else
    if ! curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash -s -- --mariadb-server-version="$2" >/dev/null 2>&1; then
        echo "Community Repo Setup Failed: Check Release Number"
        exit 1
    fi
fi
